require(['./config'],() => {
  require(['template','header','footer'],(template) => {
    class ZhouNian {
      constructor () {
        this.navinit()
        this.shopList()
        this.goDetail()
      }
      navinit () {
        $.get('http://www.xiongmaoyouxuan.com/api/tabs?sa=',resp => {
          const { list } = resp.data
          $('#tabList').html(template('renderNav',{ data: list.slice(1,8)}))
        })
      }
      shopList () {
        const id = location.search.slice(4)
        $.get(`http://www.xiongmaoyouxuan.com/api/tab/${id}`,resp => {
          const { list } = resp.data.items,
                { cname } = resp.data.category
          var arr = list.filter((item) =>{
            return item.originPrice !== undefined
          })
          $('#good_list').html(template('categoryList',{ data: arr, cname }))
        })
      }
      goDetail () {
        $('#good_list .shangpin').on('click',function () {
          location.href = '/html/detail.html'
        })
      }
    }
    return new ZhouNian()
  })
})